# encoding=utf-8
import datetime
import time
import sched
from sched import scheduler


def time_printer():
    now = datetime.datetime.now()
    ts = now.strftime('%Y-%m-%d %H:%M:%S')
    print('do func time :', ts)
    loop_monitor()


def loop_monitor():
    s = scheduler(time.time, time.sleep)  # 生成调度器
    # enter四个参数分别为：间隔事件、优先级（用于同时间到达的两个事件同时执行时定序）、被调用触发的函数，给该触发函数的参数（tuple形式）
    s.enter(1, 0, time_printer, ())
    s.run()


if __name__ == "__main__":
    loop_monitor()
